﻿using System;
namespace Producers.Taitis.Xtee.Riik.Ee.Producer.Taitis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paring3_paring", Namespace="http://producers.taitis.xtee.riik.ee/producer/taitis", Target=typeof(Paring3Paring))]
    public class Paring3ParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParing3Paring clazz;
        
        public Paring3ParingSerializer(IParing3Paring clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("tnumber");
            if (clazz.Tnumber!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tnumber))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Tnumber");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "tnumber")) {
                goto tnumber;
            }
            else {
                return;
            }
        tnumber:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring3_paring>tnumber");
            }
            clazz.Tnumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tnumber")).Value;
            goto START;
        }
    }
}
